<template>
  <div>
    <div>收付款码<a href="javascript:void(0);" @click="getOrderCode">刷新</a> </div>
    <div>{{orderCode}}</div>
    <div class="qrcode">
      <qrcode :qrUrlStr="orderCode" />
    </div>
  </div>
</template>
<script>
import Qrcode from "@/components/Qrcode.vue";

export default {
  name: "FukuanView",
  components: {
    Qrcode,
  },
  data() {
    return {
      orderCode: "20240408163112335", //订单信息,后端生成，存储在数据库中，并且有时效性，1分钟
      user_id:JSON.parse(localStorage.getItem('loginUser')).user_id,
    };
  },
  mounted() {
    //加载页面后调用接口方法，初始化uuid的订单编号
    this.getOrderCode();
  },
  methods: {
    async getOrderCode(){
        let res = await this.$http.post('randomOrderCode',{user_id:this.user_id});
        console.log(res);
        if(res.state==200){
            this.orderCode = res.data;
        }else{

        }
    }
  },
};
</script>
<style scoped>
.qrcode{
    margin: 20px auto;
}
</style>